

import time

import yaml
from selenium import webdriver
from selenium.webdriver.chrome.webdriver import Options

class TestAddMember:
    options = Options()
    options.debugger_address="localhost:9222"
    driver = webdriver.Chrome()
    driver.get("https://work.weixin.qq.com/wework_admin/loginpage_wx")
    time.sleep(2)
    cookie_var=driver.get_cookies()
    print(cookie_var)
    yaml.safe_dump(cookie_var,open("cookie.yaml",mode="w",encoding="utf-8"))

def test_cookie_login(self):
    cookie_var=yaml.safe_load(open('cookie.yaml',encoding='utf-8'))
    print(cookie_var)
    driver = webdriver.chrome()
    driver.get("https://work.weixin.qq.com/wework_admin/frame")
    for cookie in cookie_var:
        driver.add_cookie(cookie)
        time.sleep(5)
        driver.get("https://work.weixin.qq.com/wework_admin/frame")
